<template>
	<view class="content">
		<view class="padding-horizontal-main padding-top-main">
			<view class="list-item  padding-top-main border-radius-main bg-white oh spacing-mb"  v-for="(item,index) in providers" :key="index" >
				<!-- 物流名称 -->
				<view class="item-base oh  padding-bottom-main">
				    <!-- 选择 -->
				    <view  class="fl selected">
				        <!-- <image class="warehouse-group-icon va-m margin-right-sm" src="../../static/images/blue/tabbar/cart.png" mode="widthFix"></image> -->
						<text class="cr-base va-m">delivery：{{item.provider.alias}}</text>
						<text class="cr-base va-m">{{express_number}}</text>
				    </view>
				    <text class="fr cr-red"><text></text></text>
				</view>
				<view  class="goods-popup-content" >
				<!-- 签收状态 -->
				<view class="item-base oh  padding-bottom-main">
				    <!-- 选择 -->
				    <view  class="fl selected">
						<text class="margin-right-sm cr-red">{{Logistics_list.latest_status.status_name}}</text> <text></text>
				    </view>
				    <!-- <text class="fr cr-red arrow-right padding-right-xxxl" @tap="logistics_event">详细信息</text> -->
				</view>
				
				<view class="item-base oh  padding-bottom-main" v-for="(iten,inde) in item.events" :key="inde">
				    <view  class="fl selected">
						<text class="margin-right-sm">{{iten.time_utc}}</text> <text></text>
						<view class="">{{iten.description}}</view>
				    </view>
				</view>
				</view>
		</view>
	</view>
	<!-- 物流弹层 -->
<!-- 	<component-popup :propShow="popup_status" propPosition="bottom" @onclose="popup_close_event">
		<view class="goods-popup padding-main pr bg-gray ">
		<view class="close fr oh">
		    <view class="fr" @tap.stop="popup_close_event">
		        <icon type="clear" size="20"></icon>
		    </view>
		</view>
	   <view class="center">详细信息</view>
	   <view class="list-item padding-horizontal-main padding-top-main bg-white oh spacing-mb border-radius-main goods-popup-content">
	   		<view class="item-base oh  padding-bottom-main br-b-dashed">
	   		    <view  class="fl selected">
	   		        <image class="warehouse-group-icon va-m margin-right-sm" src="../../static/images/blue/tabbar/cart.png" mode="widthFix"></image>
	   				<text class="cr-base va-m">123</text>
	   		    </view>
	   		    <text class="fr cr-red">复制<text >｜电话</text></text>
	   		</view>
			<view class="item-base oh  padding-bottom-main" v-for="(item,index) in shipping_time" :key="index">
			    <view  class="fl selected">
					<text class="margin-right-sm">{{item.location}}</text> <text>{{item.time_iso}}</text>
					<view class="">{{item.description}}</view>
			    </view>
			</view>
	   </view>
	   </view>
	</component-popup> -->
	<!-- 结尾 -->
	<!-- 提示信息 -->
	<block v-if="load_status == 0">
		<component-no-data :propStatus="data_list_loding_status" :propMsg="data_list_loding_msg"></component-no-data>
	</block>
	<component-bottom-line :propStatus="data_bottom_line_status"></component-bottom-line>
	</view>
	
</template>

<script>
	 const app = getApp();
	 import componentNoData from "../../components/no-data/no-data";
	import componentBottomLine from "../../components/bottom-line/bottom-line.vue";
	export default{
		data(){
			return{
				// options:{},
				popup_status: false,
				express_number:'',//快递单号
				Logistics_list:{},
				providers:[],
				data_bottom_line_status:false,
				data_list_loding_status:1,
				data_list_loding_msg:'',
				data_status: false,
				load_status:0,
			}
			
		},
		components: {
		    componentBottomLine,
			componentNoData
		},
		onLoad(option) {
			this.express_number=option.number
			let options= option.id
			this.init(options)

		},
		// 下拉刷新
		// onPullDownRefresh() {
		//     this.init();
		// },
		methods:{
			init(options){
				if(!this.data_status) {
				    this.setData({
				        data_list_loding_status: 1,
				        data_list_loding_msg: ''
				    });
				}
				// 加载loding
				uni.showLoading({
				    title: this.$t('globalData.Processing')
				});
				uni.request({
					url: app.globalData.get_request_url("plugins", "index","trackapi","&pluginsaction=Getexpinfo"),
				    method: 'POST',
				    data: {
				        express_id:options,
						express_number:this.express_number
				    },
				    dataType: 'json',
				    success: res => {
				        uni.hideLoading();
						// 设置首次加载状态
						this.setData({
						    load_status: 1
						});
				         if (res.data.code == 0) {
							 var data = res.data.data || null;
							 var status = (data != null && ((data.msg || null) != null || ((data.data || null) != null && data.data.length > 0)));
							 console.log(status);
							 this.setData({
								 Logistics_list:res.data.data,
								 providers:res.data.data.tracking.providers.map(v=>v),
								 data_bottom_line_status:status,
								 data_list_loding_status: status ? 3 : 0,
								 data_list_loding_msg: status ? '' : this.$t('user-order.logisticss-info'),
								 
								 })
						 }else{
							 this.setData({
							     data_list_loding_status: 0,
							     data_list_loding_msg: res.data.msg
							 });
							 app.globalData.showToast(res.data.msg);
						 }
				    },
				    fail: () => {
				        uni.hideLoading();
						load_status: 1
				        app.globalData.showToast(this.$t('globalData.Server-request-error'));
				    }
				});
			},
			// 查看物流关闭
			popup_close_event(e) {
			    this.setData({
			        popup_status: false
			    });
			},
			logistics_event(){
				this.setData({
				    popup_status: true
				});
			}
		}
	}
</script>

<style>
	@import url("user-logistics.css");
</style>